package com.cn.wanxi.springtask.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @ClassName TaskConfig
 * @Description spring task的配置类
 * @Author JiJiang
 * @Date 2022/9/29 14:37
 * @Version 1.0
 */
@Configuration
public class TaskConfig {

    @Bean
    public TaskScheduler taskScheduler() {

        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        //这里如果不设置，默认只有一个线程执行定时任务
        taskScheduler.setPoolSize(50);
        return taskScheduler;
    }
}
